package reflect;


import com.sun.xml.internal.stream.StaxXMLInputSource;

import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
        person p = new person();
        System.out.println(p);

        /*
        放射机制实例化
        1.获取对应的对象
        2.通过类对象的newInstance（）方法实例化
         */

//        Class cls = person.class;
//        Object obj = cls.newInstance();
//        System.out.println(obj);

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个类的完全限定名");
        String className = scanner.nextLine();


        Class cls = Class.forName(className);
        Object obj = cls.newInstance();
        System.out.println(obj);





    }

}
